package com.jari.lg.service.profile.vehicle;

import com.jari.lg.domain.DevBase;
import com.jari.lg.domain.VehicleCpTypeEntity;
import com.jari.lg.mapper.VehicleCpTypeEntityMapper;
import com.jari.lg.utils.BaseData;
import com.jari.lg.utils.Constants;
import com.jari.lg.utils.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class VehicleCpTypeService {


    @Autowired
    private VehicleCpTypeEntityMapper vehicleCpTypeEntityMapper;

    /*
    *   交通卡口一天更新一次
    * */
    public void makeInfo(){
        VehicleCpTypeEntity entity;
        List<DevBase> devBases = BaseData.checkpointList;
        for(DevBase devBase : devBases){
            entity = generate(devBase);
            vehicleCpTypeEntityMapper.insert(entity);
        }
    }

    private VehicleCpTypeEntity generate(DevBase devBase){
        VehicleCpTypeEntity entity = new VehicleCpTypeEntity();
        entity.setCheckpointcode(devBase.getDevicecode());
        entity.setCheckpointname(devBase.getDevicename());
        entity.setCreator("SYS");
        entity.setGmtcreate(new Date());
        entity.setDate(new Date());
        entity.setDatastatus(Constants.DATA_STATUS_ONE);
        entity.setLocalcarnum(Constants.BASE_INT + Utils.makeRandInt(5000));
        entity.setNolocalcarnum(Constants.BASE_INT + Utils.makeRandInt(5000));
        entity.setProvinceset(Utils.makeRandProvince(5));
        return entity;
    }
}
